<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 求任意两个数之间的和
        var num1 = prompt('请输入第一个数');
        var num2 = prompt('请输入第2个数字');
        var sum = 0;
        function getNum(num1, num2) {
            if (num1 < num2) {
                for (var i = num1; i <= num2; i++) {
                    sum += parseInt(i);
                }
            }
            else {
                var temp = 0;
                temp = num1;
                num = num2;
                num2 = temp;
                for (var i = num1; i <= num2; i++) {
                    sum += parseInt(i);
                }

            }
            console.log(sum);
            alert(sum);
        }

        getNum(num1, num2);


    </script>
</head>

<body>
    <!-- ar temp = 0;
    temp = num1;
    num = num2;
    num2 = temp; -->
</body>

</html>